<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header('新增流程')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-process-save" method="post">
        <div class="form-group">
            <label class="col-sm-3 control-label">流程文件：</label>
            <div class="col-sm-8">
                <input class="form-control" id="file" name="file" type="file">
                 <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 文件格式仅支持zip</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">流程类别：</label>
            <div class="col-sm-8">
                <input class="form-control" id="category" name="category" th:type="input">
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" th:inline="javascript">
	var prefix = ctx + "activiti/process";
	function submitHandler() {
	    uploadFile();
	}
	function uploadFile() {
	    var formData = new FormData();
	    if($('#file')[0].files[0] == null) {
	        $.modal.alertWarning("请先选择文件路径");
	        return false;  
	    }
	    formData.append('file', $('#file')[0].files[0]);
	    formData.append('category', document.getElementById("category").value);
	    $.ajax({
	        url: prefix + "/add",
	        type: 'post',
	        cache: false,
	        data: formData,
	        processData: false,
	        contentType: false,
	        dataType: "json",
	        success: function(result) {
	            $.operate.successCallback(result);
	        }
	    });
	}
</script>
</body>
</html>
